package icu.yougan.trade.controller;

import icu.yougan.trade.enums.ErrorMsg;
import icu.yougan.trade.service.FileService;
import icu.yougan.trade.utils.AliOSSUploadUtils;
import icu.yougan.trade.utils.IdFactoryUtil;
import icu.yougan.trade.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @Author:Lee
 * @changeByLyh
 * @Date:2024/5/21 11:31
 * @Version:v1.0.0
 * @Description:文件上传控制类
 **/
@RestController
@RequestMapping("file")
public class FileController {
    @Autowired
    AliOSSUploadUtils aliOSSUploadUtils;
    @RequestMapping("/upload")
    public R uploadFile(MultipartFile file) throws IOException
    {
        String s = aliOSSUploadUtils.uploadImage(file);
        return R.success(s);
    }
}
